<div class="clear"></div>
<div style="height: 40px;width: 100%;text-align: center">
    <h1 class="pt8 pb8 mt0 mb0">
        {{if isset($item)}}
            Chỉnh Sửa :{{$item->name}}
        {{else}}
            Thêm mới
        {{/if}}
    </h1>
</div>
<div class="grid24">
    <div class="pl20 pr20">
        <table style="width:100%;" class="_form">
                    <tr>
                        <td style="">
                            <div class="_input-label">
                                <div class="input">
                                    <input type="text" id="txt_product_detail_name" placeholder="" 
                                           value="{{if isset($item)}}{{$item->name}}{{/if}}"/>
                                    <input type="hidden" id="txt_product_detail_id" placeholder="" 
                                        value="{{if isset($item)}}{{$item->id}}{{/if}}"/>
                                    <div class="label"><label>Name</label></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="_input-label" type="select">
                                <div class="input" type="select">
                                    <div class="select">
                                        <select id="cbx_product_detail_game">
                                            <option value="Bóng Đá">Bóng Đá</option>

                                        </select>
                                    </div>
                                    <div class="label"><label>Game</label></div>
                                </div>
                            </div>
                            
                        </td>
                    </tr>
                    <tr>
                        <td style="position: relative">
                            <div class="_input-label">
                                <div class="input">
                                    <input type="text" id="txt_product_detail_start" placeholder="" 
                                           value="{{if isset($item)}}{{$item->startdate}}{{/if}}"/>
                                    <div class="label"><label>Start Date</label></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td style="position: relative">
                            <div class="_input-label">
                                <div class="input">
                                    <input type="text" id="txt_product_detail_end" placeholder="" 
                                           value="{{if isset($item)}}{{$item->enddate}}{{/if}}"/>
                                    <div class="label"><label>End Date</label></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td style="position: relative">
                            <div class="_input-label">
                                <div class="input">
                                    <input type="text" id="txt_product_detail_type" placeholder="" 
                                           value="{{if isset($item)}}{{$item->type}}{{/if}}"/>
                                    <div class="label"><label>Type</label></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td style="position: relative">
                            <div class="_input-label" type="select">
                            <div class="input" type="select">
                                <div class="select">
                                    <select id="cbx_product_detail_category">
                                        <option value="HTML5 Template">HTML5 Template</option>
                                        
                                    </select>
                                </div>
                                <div class="label"><label>Category</label></div>
                            </div>
                            </div>
                        </td>
                    </tr>
                    
                    <tr>
                        <td colspan="" style="text-align: left">
                            {{if isset($item->insert)}}
                                <span style="color: blue">Thêm lúc : {{if isset($item)}}{{$item->insert}}{{/if}}</span>
                            {{/if}}
                            {{if isset($item->update)}}
                                <br/><span style='color: orange'>Cập nhật lúc : {{if isset($item)}}{{$item->update}}{{/if}}</span>
                            {{/if}}
                            {{if isset($item->delete)}}
                                <br/><span style='color: red'>Xóa lúc : {{if isset($item)}}{{$item->delete}}{{/if}}</span>
                            {{/if}}
                            
                        </td>
                    </tr>
                </table>
        <span id="warningmsg"></span>
        <div class="mybutton icon tooltip" 
            title="Tải Lại"
            onclick="load_product_detail({{if isset($item)}}'{{$item->id}}'{{else}}null{{/if}});"
            ><div><img src="{{base_url()}}images/icon/arrow_refresh1.png"/><span>Tải lại</span></div></div>
        <div class="mybutton icon tooltip{{if isset($item->delete)}} disable{{/if}}" 
            title="Lưu"
            onclick="{{if !isset($item->delete)}}{{if isset($item->id)}}update();{{else}}save();{{/if}}{{/if}}"
            ><div><img src="{{base_url()}}images/icon/media_floppy_green.png"/><span>Lưu</span></div></div>
        <div class="mybutton icon tooltip" 
            onclick="huy()"
            title="Hủy"
            ><div><img src="{{base_url()}}images/icon/16/Cancel.png"/><span>Hủy</span></div></div>
        <div class="clear"></div>
    </div>
</div>
<script>
    $(document).ready(function(){
//        $("#txt_product_detail_start,#txt_product_detail_end").datetimepicker({ampm: false,dateFormat: 'yy-mm-dd', });
        
        $('#txt_product_detail_start').datetimepicker({
            ampm: false,dateFormat: 'yy-mm-dd',
            onClose: function(dateText, inst) {
                var endDateTextBox = $('#txt_product_detail_end');
                if (endDateTextBox.val() != '') {
                    var testStartDate = new Date(dateText);
                    var testEndDate = new Date(endDateTextBox.val());
                    if (testStartDate > testEndDate)
                        endDateTextBox.val(dateText);
                }
                else {
                    endDateTextBox.val(dateText);
                }
            },
            onSelect: function (selectedDateTime){
                var start = $(this).datetimepicker('getDate');
                $('#txt_product_detail_end').datetimepicker('option', 'minDate', new Date(start.getTime()));
            }
        });
        $('#txt_product_detail_end').datetimepicker({
            ampm: false,dateFormat: 'yy-mm-dd',
            onClose: function(dateText, inst) {
                var startDateTextBox = $('#txt_product_detail_start');
                if (startDateTextBox.val() != '') {
                    var testStartDate = new Date(startDateTextBox.val());
                    var testEndDate = new Date(dateText);
                    if (testStartDate > testEndDate)
                        startDateTextBox.val(dateText);
                }
                else {
                    startDateTextBox.val(dateText);
                }
            },
            onSelect: function (selectedDateTime){
                var end = $(this).datetimepicker('getDate');
                $('#txt_product_detail_start').datetimepicker('option', 'maxDate', new Date(end.getTime()) );
            }
        });
        
        $("#txt_product_detail_name").focus();
        tinyMCE.init({
                mode : "textareas",
                theme : "advanced",
                editor_selector : "mceEditor",
                editor_deselector : "mceNoEditor",
                theme_advanced_resizing : true,
                theme_advanced_resize_horizontal : false
        });
    });

</script>
